package com.lyswkjxgs.report.controller;

import com.lyswkjxgs.report.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionAdvice {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public AjaxResult<String> exHandle(Exception e){
        logger.warn("异常拦截", e);
        return AjaxResult.error(e.getMessage());
    }
}
